if g:git_plugin_name.cur_val ==# 'gina.vim' && te#env#SupportAsync()
    Plug 'lambdalisue/gina.vim'
    nnoremap  <silent><F3> :Gina status<cr>
    " Open git status window
    nnoremap  <silent><Leader>gs :Gina status<cr>
    " Open github url
    nnoremap  <silent><Leader>gh :Gina browse<cr>
    " Open git blame windows
    nnoremap  <silent><Leader>gb :Gina blame --use-author-instead :<cr>
    " show branch
    nnoremap  <silent><Leader>sb :Gina branch -a<cr>
    " show tag
    nnoremap  <silent><Leader>st :Gina tag<cr>
    " git diff current file
    nnoremap  <silent><Leader>gd :Gina compare :<cr>
    " git cd
    nnoremap <silent><Leader>gc :Gina cd<cr>:call te#utils#EchoWarning(getcwd())<cr>
    " git config -e
    nnoremap  <silent><Leader>ge :Gina cd<cr>:sp .git/config<cr>

    function! StageNext(count) abort
        for i in range(a:count)
            call search('^\t.*','W')
        endfor
        return '.'
    endfunction

    function! StagePrevious(count) abort
        if line('.') == 1 && exists(':CtrlP') && get(g:, 'ctrl_p_map') =~? '^<c-p>$'
            return 'CtrlP '.fnameescape(s:repo().tree())
        else
            for i in range(a:count)
                call search('^\t.*','Wbe')
            endfor
            return '.'
        endif
    endfunction

    function s:gina_setting()
        call gina#custom#command#option('status', '--opener', &previewheight . 'split')
        call gina#custom#command#option('commit', '--opener', &previewheight . 'split')
        call gina#custom#command#option('status', '--group', 'short')
        call gina#custom#command#option('commit', '--group', 'short')
        "log windows
        silent! call gina#custom#mapping#nmap(
                    \ 'log', 'yy',
                    \ ':call gina#action#call(''yank:rev'')<CR>',
                    \ {'noremap': 1, 'silent': 0},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'log', '<c-n>',
                    \ 'j:call gina#action#call(''show:preview'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'log', '<c-p>',
                    \ 'k:call gina#action#call(''show:preview'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'log', '<cr>',
                    \ ':call gina#action#call(''show:preview'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'log', '<c-t>',
                    \ ':call gina#action#call(''show:tab'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'log', '<tab>',
                    \ '<c-w>w',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        "blame windows
        silent! call gina#custom#mapping#nmap(
                    \ 'blame', '<cr>',
                    \ ':call gina#action#call(''show:commit:tab'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        "branch windows
        silent! call gina#custom#mapping#nmap(
                    \ 'branch', 'cc',
                    \ ':call gina#action#call(''checkout:track'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        "status windows
        let g:gina#command#status#use_default_mappings=0
        silent! call gina#custom#mapping#nmap(
                    \ 'status', 'cc',
                    \ ':<C-u>Gina commit --signoff<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', '<cr>',
                    \ ':call gina#action#call(''edit'')<CR>',
                    \ {'noremap': 1, 'silent': 0},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', 'yy',
                    \ ':call gina#action#call(''yank:path'')<CR>',
                    \ {'noremap': 1, 'silent': 0},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', '-',
                    \ ':call gina#action#call(''index:toggle'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', 'e',
                    \ ':call gina#action#call(''diff'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#vmap(
                    \ 'status', '-',
                    \ ':call gina#action#call(''index:toggle'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', '<c-n>',
                    \ ':<C-U>execute StageNext(v:count1)<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', '<tab>',
                    \ ':<C-U>execute StageNext(v:count1)<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', '<c-p>',
                    \ ':<C-U>execute StagePrevious(v:count1)<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', 'ca',
                    \ ':<C-u>Gina commit --amend --signoff<CR>:0<cr>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'commit', 'cc',
                    \ ':<C-u>Gina status<CR>:0<cr>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', 'U',
                    \ ':call gina#action#call(''index:discard'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', 'u',
                    \ ':call gina#action#call(''checkout'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#vmap(
                    \ 'status', 'u',
                    \ ':call gina#action#call(''checkout'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', 'd',
                    \ ':call gina#action#call(''patch'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'status', 'D',
                    \ ':call gina#action#call(''compare'')<CR>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ '/.*', 'q',
                    \ ':call te#utils#quit_win(0)<cr>',
                    \ {'noremap': 1, 'silent': 1},
                    \)
        "let g:gina#command#status#use_default_mappings=0
        silent! call gina#custom#mapping#nmap(
                    \ 'blame', 'yy',
                    \ ':call gina#action#call(''yank:rev'')<CR>',
                    \ {'noremap': 1, 'silent': 0},
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'blame', 'j',
                    \ 'j<Plug>(gina-blame-echo)'
                    \)
        silent! call gina#custom#mapping#nmap(
                    \ 'blame', 'k',
                    \ 'k<Plug>(gina-blame-echo)'
                    \)
        call gina#custom#execute('commit', 'setlocal omnifunc=github_complete#complete nofoldenable cursorline')
        call gina#custom#execute('status', 'setlocal nofoldenable cursorline')
        let g:gina#component#repo#commit_length=6
    endfunction

    call te#feat#register_vim_enter_setting(function('<SID>gina_setting'))
else
    "fallback option
    let g:git_plugin_name.cur_val = 'vim-fugitive'
    Plug 'tpope/vim-fugitive'
    Plug 'gregsexton/gitv', { 'on': 'Gitv' }
    Plug 'sodapopcan/vim-twiggy', { 'on': 'Twiggy' }
    let g:fugitive_no_maps=0
    nnoremap  <silent><Leader>sb :Twiggy<cr>
    nnoremap  <silent><F3> :silent! only<cr>:Gstatus<cr>:call feedkeys(']]')<cr>
    " Open git status window
    nnoremap  <silent><Leader>gs :silent! only<cr>:Gstatus<cr>:call feedkeys(']]')<cr>
    " Open git log( browser mode)
    " Open git log(file mode)
    nnoremap  <silent><Leader>gL :Gitv! --all<cr>
    " Open git log(file mode)
    vnoremap  <silent><leader>gL :Gitv! --all<cr>
    " Open git blame windows
    nnoremap  <silent><Leader>gb :Gblame<cr>
    " git diff current file (vimdiff)
    nnoremap  <silent><Leader>gd :Gdiff<cr>
    " git cd
    nnoremap  <silent><Leader>gc :Gcd<cr>:call te#utils#EchoWarning(getcwd())<cr>
    " git config -e
    nnoremap  <silent><Leader>ge :Gcd<cr>:sp .git/config<cr>
    " Open github url
    nnoremap  <silent><Leader>gh :call te#git#git_browse()<cr>
endif

nnoremap gho :call te#git#browse_file(1)<cr>
xmap gho :<c-u>call te#git#browse_file(3)<cr>

nnoremap ghc :call te#git#browse_file(0)<cr>
xmap ghc :<c-u>call te#git#browse_file(2)<cr>

nnoremap  <silent><Leader>gl :call te#git#show_log(".")<cr>
if te#env#SupportPy2()
    Plug 'jaxbot/github-issues.vim', { 'on': 'Gissue' }
endif
Plug 'rhysd/github-complete.vim',{'for': ['gitcommit', 'markdown', 'gina-commit']}
if te#env#SupportFeature('signs')
    Plug 'airblade/vim-gitgutter', { 'on': [] }
    call te#feat#register_vim_plug_insert_setting(['GitGutterEnable'], 
                \ ['vim-gitgutter'])
endif
if te#env#SupportAsync()
    Plug 'rhysd/git-messenger.vim',{'on': '<Plug>(git-messenger)'}
    nmap  <silent><Leader>gn <Plug>(git-messenger)
    let g:git_messenger_no_default_mappings=v:true
endif

" Git releate ---------------------{{{
" list git issue
nnoremap  <silent><Leader>gi :silent! Gissue<cr>
" create new github issue
nnoremap  <silent><Leader>ga :silent! Giadd<cr>
" git merge
nnoremap  <silent><Leader>gm :call te#git#git_merge()<cr>
" arhcive vim config.
nnoremap  <silent><leader>gA :call te#git#archive_my_vim_cfg($VIMFILES,'vim_config')<cr>
" archive current git repo with default name
nnoremap  <silent><leader>gC :call te#git#archive_my_vim_cfg('.','')<cr>
let g:gissues_lazy_load = 1
let g:gissues_async_omni = 1
if filereadable($VIMFILES.'/.github_token')
    let g:github_access_token = readfile($VIMFILES.'/.github_token', '')[0]
endif
" git push origin master
nnoremap  <silent><Leader>gp :call te#git#GitPush("heads")<cr>
" git push to gerrit
nnoremap  <silent><Leader>gg :call te#git#GitPush("for")<cr>
" git fetch all
nnoremap  <silent><Leader>gf :call te#utils#run_command('git fetch --all')<cr>
"}}}
